// eslint-disable-next-line strict
function checktoken() {
  return async function(ctx, next) {
    // 验证token
    try {
      const token = ctx.header.token;
      ctx.app.jwt.verify(token, ctx.app.config.secret);
      await next();
    } catch (e) {
      ctx.body = {
        code: 40000,
        msg: 'token验证失败',
      };
    }

  };
}

module.exports = checktoken;
